_find_package(${ARGS})

set(_tiff_features ";@FEATURES@;")
set(_tiff_link_libraries "")
set(_tiff_libraries "")
if(_tiff_features MATCHES ";webp;")
    find_package(WebP CONFIG REQUIRED)
    list(APPEND _tiff_link_libraries WebP::WebP)
    list(APPEND _tiff_libraries ${WEBP_LIBRARIES})
endif()
if(_tiff_features MATCHES ";lzma;")
    find_package(LibLZMA CONFIG REQUIRED)
    list(APPEND _tiff_link_libraries LibLZMA::LibLZMA)
    list(APPEND _tiff_libraries ${LZMA_LIBRARIES})
endif()
if(_tiff_features MATCHES ";jpeg;")
    find_package(JPEG REQUIRED)
    list(APPEND _tiff_link_libraries JPEG::JPEG)
    list(APPEND _tiff_libraries ${JPEG_LIBRARIES})
endif()
if(_tiff_features MATCHES ";zstd;")
    find_package(ZSTD CONFIG REQUIRED)
    if(TARGET zstd::libzstd_shared)
        set(_tiff_zstd zstd::libzstd_shared)
    else()
        set(_tiff_zstd zstd::libzstd_static)
    endif()
    list(APPEND _tiff_link_libraries ${_tiff_zstd})
    list(APPEND _tiff_libraries ${_tiff_zstd})
endif()
if(_tiff_features MATCHES ";zip;")
    find_package(ZLIB REQUIRED)
    list(APPEND _tiff_link_libraries ZLIB::ZLIB)
    list(APPEND _tiff_libraries ${ZLIB_LIBRARIES})
endif()
if(UNIX)
    list(APPEND _tiff_link_libraries m)
    list(APPEND _tiff_libraries m)
endif()

if(TARGET TIFF::TIFF)
  set_property(TARGET TIFF::TIFF APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${_tiff_link_libraries})
endif()
if(TIFF_LIBRARIES)
  list(APPEND TIFF_LIBRARIES ${_tiff_libraries})
endif()
if(TIFF_LIBRARY)
  list(APPEND TIFF_LIBRARY ${_tiff_libraries})
endif()
